﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ZombieGame
{
    public class Menu
    {
        public static void LoadMenus()
        {
            test = new Menu();
            test.Components.Add(new GUIText("Hello Everyone\nHello Hello") { Position = new Vector2(150f), LineSpacing = 2f, Alignment = TextAlignment.CenterCenter, Color = Color.Black });
            test.Components.Add(new GUIText("Test: ") { Position = new Vector2(150f, 200f), Color = Color.Black });
            test.Components.Add(new GUITextbox() { Position = new Vector2(220f, 200f), Color = Color.Black, Size = new Vector2(16f, 16f) });
            MainMenu = new Menu();
            MainMenu.Components.Add(new GUIText("Project Undead") { Position = new Vector2(ZombieGame.Current.GraphicsDevice.Viewport.Width / 2f, 100f), Color = Color.Black, Alignment = TextAlignment.CenterCenter });
            MainMenu.Components.Add(new GUIText("Name: ") { Position = new Vector2(10f, 200f), Color = Color.Black });
            MainMenu.Components.Add(new GUITextbox() { Position = new Vector2(90f, 200f), Color = Color.Black, Size = new Vector2(14f, 70f) });
            MainMenu.Components.Add(new GUIButton(new Vector2(50f, 230f), "Solo")
            {
                Color = Color.Black,
                OnClick = (GUIButton b) =>
                {
                    ZombieGame.Current.Menu = null;
                    ZombieGame.Current.World = World.LoadWorld("testmapcomplete.puw");
                    Player p = new Player();
                    p.Position = ZombieGame.Current.World.PSpawners[0];
                    ZombieGame.Current.Player = p;
                    ZombieGame.Current.World.Players.Add(p);
                    Camera.Enabled = true;
                    ZombieGame.Playtime.Start();
                }
            });
        }
        public static Menu test;
        public static Menu MainMenu;
        public List<GUIItem> Components;
        public Texture2D Background;
        public Menu()
        {
            Components = new List<GUIItem>();
        }

        public void Update(GameTime time)
        {
            for (int i = 0; i < Components.Count; i++)
                Components[i].Update(time);
        }
        public void Draw(SpriteBatch batch)
        {
            if (Background != null)
                batch.Draw(Background, new Vector2(), Color.White);
            for (int i = 0; i < Components.Count; i++)
                Components[i].Draw(batch);
        }
    }
}
